/**
 * 值为空时返回默认值
 * @param {Object} val
 * @param {Object} def
 */
export const defaultValue = function (val, def) {
    if (val === undefined || val === null || val === '') {
        if (def === undefined || def === null)
            return "";
        else
            return def;
    } else {
        return val;
    }
}

/**
 * 值为空时返回''
 * @param {Object} val
 */
export const defaultEmpty = function (val) {
    return defaultValue(val, '')
}

/**
 * 是否为undefind
 * @param {Object} val 
 * @returns 
 */
export const isUndefind = function(val) {
    return val === undefined;
}

/**
 * 是否为undefind null
 * @param {Object} val 
 * @returns 
 */
export const isNull = function(val) {
    return val === undefined || val === null;
}

/**
 * 是否为undefind null ''
 * @param {Object} val 
 * @returns 
 */
export const isEmpty = function(val) {
    return val === undefined || val === null || val === '';
}

/**
 * 不为undefind
 * @param {Object} val 
 * @returns 
 */
export const isNotUndefind = function(val) {
    return !isUndefind(val);
}

/**
 * 不为undefind null
 * @param {Object} val 
 * @returns 
 */
export const isNotNull = function(val) {
    return !isNull(val);
}

/**
 * 不为undefind null ''
 * @param {Object} val 
 * @returns 
 */
export const isNotEmpty = function(val) {
    return !isEmpty(val);
}